package com.df.ez_game.server.gateway;

import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.unix.Buffer;

public class GateWayClientInHandler extends SimpleChannelInboundHandler<ByteBuf> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf buffer) throws Exception {
        int length = buffer.readInt();

        // 消息
        byte[] msgBytes = new byte[length-4];
        buffer.readBytes(msgBytes);
//        try {
//            Codec<GateWayReqMsg> codec = ProtobufProxy.create(GateWayReqMsg.class);
//            GateWayReqMsg decode = codec.decode(msgBytes);
//            UserManager.lifeCycle(handler->handler.receiveMsg(ctx,decode,true));
//            out.add(decode);
//        }catch (Exception e){
//            UserManager.lifeCycle(handler->handler.receiveMsg(ctx,null,false));
//            log.error(e.getMessage(),e);
//        }
    }
}
